$('.sousu').click(function(){
	$('.dizhisouso').css({
		display:'block'
	})

	// 百度地图API功能
	var map = new BMap.Map("");        


	var options = {
		onSearchComplete: function(results){
			// 判断状态是否正确
			if (local.getStatus() == BMAP_STATUS_SUCCESS){
				var a;
				$('.dizhisouso').empty();
				for (var i = 0; i < results.getCurrentNumPois(); i ++){  
					/*s.push(results.getPoi(i).title + ", " + results.getPoi(i).address);*/
				    var point=results.getPoi(i).point;
                    var p = "<p class='adresskk'  onclick=\"selectadressClick1('"+point.lng+"','"+point.lat+"','"+results.getPoi(i).address+"')\">"+results.getPoi(i).address+"</p>"


					$('.dizhisouso').append(p);
					/*console.log(point.lat);
                    console.log(point.lng);*/
				}
			}
		}
	};
	var local = new BMap.LocalSearch(map, options);
	local.search($('.selecity').text()+$('.shuruydixzi').val());
 
})


	
   
function selectadressClick1(lat,lng,d){
	$('.dituweizhi').css({ 
 		display:'block'
 	})

    $.ajax({
        type:'post',
        url:'/gpsWX/gpsSaveAddress',
        data:{"latitude":lat,"longitude":lng,"accuracy":0,"state":0},
        dataType:'json',
        success:function (reslut) {

            $('.weixzhixinxi').text(d);

        }
    })

 	$('.dizhisouso').css({
 		display:'none'
 	})
 
 	console.log(lat);
	console.log(lng);

}
$('#xiandadress').click(function(){
    $('.mapalert').css({
        display: 'block'
    })





})
$('.shousuo').click(function(){
    // 百度地图API功能
    var map = new BMap.Map("");
    /*map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);*/


    var options = {
        onSearchComplete: function(results){
            // 判断状态是否正确
            if (local.getStatus() == BMAP_STATUS_SUCCESS){
                var a;
                $('#resultd').empty();
                for (var i = 0; i < results.getCurrentNumPois(); i ++){
                    /*s.push(results.getPoi(i).title + ", " + results.getPoi(i).address);*/
                    var point=results.getPoi(i).point;
                    var p = "<p class='adresskk'  onclick=\"selectadressClick('"+point.lng+"','"+point.lat+"','"+results.getPoi(i).address+"')\">"+results.getPoi(i).title+"</p>"
                    $('#resultd').append(p);
                }
            }
        }
    };
    var local = new BMap.LocalSearch(map, options);
    local.search($('#tobaiduCity').val()+$('.shurudizi').val());

})
function  getInput() {
    // 百度地图API功能
    var map = new BMap.Map("");
    /*map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);*/


    var options = {
        onSearchComplete: function(results){
            // 判断状态是否正确
            if (local.getStatus() == BMAP_STATUS_SUCCESS){
                var a;
                $('#resultd').empty();
                for (var i = 0; i < results.getCurrentNumPois(); i ++){
                    /*s.push(results.getPoi(i).title + ", " + results.getPoi(i).address);*/
                    var point=results.getPoi(i).point;
                    var p = "<p class='adresskk'  onclick=\"selectadressClick('"+point.lng+"','"+point.lat+"','"+results.getPoi(i).address+"')\">"+results.getPoi(i).title+"</p>"
                    $('#resultd').append(p);
                }
            }
        }
    };
    var local = new BMap.LocalSearch(map, options);
    local.search($('#tobaiduCity').val()+$('.shurudizi').val());

}

function selectadressClick(lng,lat,titile){
    $('.dituweizhi').css({
        display:'block'
    })
    console.log(titile);
    $('#xiandadress').val(titile);

    $('.mapalert').css({
        display:'none'
    })
    $('.dangqianweizhi').css({
        display:'block'
    })
    var map = new BMap.Map("");
    var point = new BMap.Point(116.331398,39.897445);
    var myGeo = new BMap.Geocoder();
    // 将地址解析结果显示在地图上,并调整地图视野
    console.log(lng);
    console.log(lat);
    $('#longitude').val(lng);
    $('#dimension').val(lat);
}
